#ifndef _LIB_NET
#define _LIB_NET

typedef struct HEADER
{
	unsigned int packet_id;
	unsigned int body_size;
}packet_header;

/***
 * Programming Definitions
 */
#define net_true 		1
#define net_false 		0
/***/

/***
 * Networking Definitions
 */
#define SOCKET_FAILURE 				-1
#define SET_SOCKET_OPT_FAILURE	 	-2
#define BIND_FAILURE				-3
#define LISTEN_FAILURE				-4
#define ACCEPT_FAILURE				-5
#define NO_HOST_FAILURE				-6 
#define CONNECTION_FAILURE			-7
#define SEND_FAILURE				-8
#define RECV_FAILURE				-9
#define RECV_FAILURE_BODYSIZE		-10
/***/

/***
 * Definitions for Network Setting
 */
#define RECV_BUFF	4096 *10
#define net_check_active(x,f)	FD_ISSET(x,f)
/***/

extern int net_open_connection(int, struct sockaddr_in*);
extern int net_open_server_socket(int port);
extern int net_connect(char* srv_addr, int port);
extern int net_send(int _socket, packet_header* pack_header, void* pack_body);
extern int net_recv(int _socket, packet_header* pack_header, unsigned char* pack_body);
#endif
